<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>																			
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>																																			
<html lang="en">
<style>

</style>
<body>																																														
	<div id="content">																																										
		<div id="content-header"></div>																																						
		<div class="container-fluid">																																							
			<div class="" style="font-size:15px;padding:15px 5px 5px 5px;">																																					
				<form id="serviceNodeForm" url=""  action="" method="post">
					<label style="display:inline">服务节点:</label>
					<input style="display:none;" type="text" />
					<input  type="text" class="" name="ServiceNodeSearch" placeholder="全部" size=""  maxlength="" />&nbsp;&nbsp;
					<label style="display:inline">主机地址:</label>
					<input  type="text" class="" name="hostMachineAddressSearch" placeholder="全部" size=""  maxlength="" />&nbsp;&nbsp;
					<button id="filter" type="button" class="btn btn-info" style="margin-bottom:5px;padding: 2px 5px;"  onclick="load()">&nbsp;&nbsp;&nbsp;过&nbsp;滤&nbsp;&nbsp;&nbsp;</button>
		    	</form>
		    </div>																																											
			<table id="serviceNodeTable" url="" class="mytable">																	
				<thead>																																									
					<tr role="row">																																					
						<th class="ui-state-default" role="columnheader"  style="" name="serviceNode" primaryKey="true" >服务节点</th> 										
						<th class="ui-state-default" role="columnheader"  style="" name="hostMachineAddressString">主机地址</th> 										
					</tr>																																								
				</thead>																																								
				<tbody id="serviceNodeTable-tbody" role="alert" aria-live="polite" aria-relevant="all">																										
				</tbody>																																								
			</table>
		</div>																																													
	</div>																																														
</body>																																														
<script type="text/javascript">																																						
$(document).ready(function(){
	load();
	//1分钟刷新一次
	setInterval(load,60*1000);

});		


function load(){
	$("#serviceNodeForm").attr("action","<%=path%>/sysRunManage/getServiceNodes")
	$("#serviceNodeForm").ajaxSubmit(function(text){	
	    if(text.success){	
			var data = text.data;
			var _ths = [];      //标题行
			var _primaryKey = [] ;  //唯一索引字段				
			$("#serviceNodeTable").find("thead tr th").each(function(){
				var $this = $(this) ;
				_ths.push($this.attr("name"));
				if($this.attr("primaryKey")=="true"){
					_primaryKey.push($this.attr("name")) ;
				}
			});
			var tbody = loadData(data,_ths,_primaryKey);
			$("#serviceNodeTable").find("tbody").html(tbody);
	     }																																										
	});	
}

function loadData(data,_ths,_primaryKey){
	var tbody = "";
	for(var i=0;i<data.length;i++){
		var tr = '<tr class="gradeA ">';
		for(var index in _ths){
			if(_ths[index]!="work-box"){
				var td_text = ((data[i][_ths[index]]==null)?"":data[i][_ths[index]]);
				tr+='<td class=" " >'+ td_text +'</td>';
			}else if(_ths[index]=="work-box"){
				tr+='<td class="center ">';
				tr+='<a href="#" onclick="edit($(this))"><span class="glyphicon glyphicon-pencil"></span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="del($(this))"><span><span class="glyphicon glyphicon-remove"></span></span></a>';
				tr+='<form action="" method="post">';
				for(var key in _primaryKey){
					tr+='<input type="hidden" name="'+ _primaryKey[key] +'" value="'+ data[i][_primaryKey[key]] +'"/>';
				}
				tr+='</form>';
				tr+='</td>';
			}
		}
		 '</tr>' ;
		 tbody+=tr;	 
	}
	return tbody ;
}

/****
 * 启停ibma ,ibas
 */
function executeIbcmd(_this,cmd){
	var u = _this.parent().parent();
	var param = {} ;
	param.ip = u.attr("ip") ;
	param.ip = "172.16.68.110" ;
	//param.port = u.attr("port") ;
	param.cmd = cmd ;
	console.log(param);
	$.ajax({
		url:"<%=path%>/sysRunManage/executeIbcmd",
		type:"post",
		data:param,
		success:function(text){
			console.log(text);
			if(text.success){
				if(text.data=="true"){
					load();
				}else{
					alert("操作异常！");
				}
			}
		}
	});
}


/****
 * 启停Node节点
 */
function executeIbmsCmd(_this,cmd){
	$.ajax({
		url:"<%=path%>/sysRunManage/executeIbmsCmd",
		type:"post",
		data:{"cmd":cmd},
		success:function(text){
			console.log(text);
			if(text.success){
				load();
				/*
				if(text.data=="true"){
					load();
				}else{
					alert("操作异常！");
				}
				*/
			}
		}
	});
}


</script>																																												
</html>	    																																												

